<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryRef"
      :inline="true"
      v-show="showSearch"
    >
      <el-form-item label="合同编号" prop="contractNo">
        <el-input
          v-model="queryParams.contractNo"
          placeholder="请输入合同编号"
          clearable
          style="width: 200px"
          @keyup.enter="handleQuery"
        />
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          @click="handleExport"
          v-hasPermi="['system:contract:transactionType:add']"
          >导出</el-button
        >
      </el-col>
      <right-toolbar
        v-model:showSearch="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>
    <el-row :gutter="10">
      <el-col :span="24">
        <div style="text-align: right; font-size: 16px; margin-bottom: 8px">
          单位:万元
        </div>
      </el-col>
    </el-row>
    <el-table
      v-loading="loading"
      :data="dataList"
      border
      show-summary
      @selection-change="handleSelectionChange"
    >
      <el-table-column label="项目" align="center" prop="regionName" />
      <el-table-column label="本日成交套数" align="center" prop="daySetsNum" />
      <el-table-column label="本日收入" align="center">
        <el-table-column
          align="center"
          prop="dayAmountManyPrice"
          label="小计"
        />
        <el-table-column
          align="center"
          prop="dayCompanyManageManyPrice"
          label="公司管理费"
        />
        <el-table-column
          align="center"
          prop="dayStoreCommissionManyPrice"
          label="店面返佣"
        />
      </el-table-column>
      <el-table-column
        label="本月累计成交套数"
        align="center"
        prop="monthSetsNum"
      />
      <el-table-column label="本月累计收入" align="center">
        <el-table-column
          align="center"
          prop="monthAmountManyPrice"
          label="小计"
        />
        <el-table-column
          align="center"
          prop="monthCompanyManageManyPrice"
          label="公司管理费"
        />
        <el-table-column
          align="center"
          prop="monthStoreCommissionManyPrice"
          label="店面返佣"
        />
      </el-table-column>

      <!-- <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template #default="scope">
          <el-button
            link
            type="primary"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:contract:transactionOrder:edit']"
            >修改</el-button
          >
        </template>
      </el-table-column> -->
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script setup name="EveningPaper">
import { eveningPaper } from "@/api/dailyNewspaper/paper";
const { proxy } = getCurrentInstance();
const { sys_normal_disable } = proxy.useDict("sys_normal_disable");
import { reactive } from "vue";
const dataList = ref([]);
const open = ref(false);
const openDetail = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const title = ref("");
const data = reactive({
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    isTop: 2,
    contractNo: "",
  },
  rules: {},
});

const { queryParams, rules } = toRefs(data);
const form = ref({});

/** 查询岗位列表 */
function getList() {
  loading.value = true;
  eveningPaper(queryParams.value).then((response) => {
    dataList.value = response.data;
    total.value = response.total;
    loading.value = false;
  });
}
/** 取消按钮 */
function cancel() {
  open.value = false;
  reset();
}

/** 表单重置 */
function reset() {
  form.value = {};
  proxy.resetForm("postRef");
}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
}

/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef");
  handleQuery();
}

/** 多选框选中数据 */
function handleSelectionChange(selection) {
  ids.value = selection.map((item) => item.postId);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
}

/** 导出按钮操作 */
function handleExport() {
  proxy.download(
    "/system/saleDetails/export",
    {
      ...queryParams.value,
    },
    `addDetails_${new Date().getTime()}.xlsx`
  );
}

getList();
</script>
<style scoped>
.buyer-payment-form {
  font-family: SimSun, serif;
  padding: 20px;
  font-size: 14px;
  background: #fff;
  width: 900px;
  margin: 0 auto;
  border: 1px solid #000;
}
.title {
  text-align: center;
  font-size: 20px;
  font-weight: bold;
  margin-bottom: 20px;
}
.table {
  display: table;
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
}
.table-row {
  display: table-row;
}
.cell {
  display: table-cell;
  border: 1px solid #000;
  padding: 6px 10px;
  vertical-align: middle;
  min-height: 30px;
}
.header {
  background: #f0f0f0;
  font-weight: bold;
  text-align: center;
}
.input {
  padding: 4px 6px;
}
.label {
  background: #f9f9f9;
  font-weight: bold;
  width: 140px;
}
.readonly {
  background: #f9f9f9;
  text-align: center;
}
.subtotal {
  font-weight: bold;
  background: #f4f8ff;
  text-align: left;
}
.total-table .total {
  font-weight: bold;
  background: #e1f3ff;
  text-align: center;
}
.group-table {
  margin-top: 10px;
}
</style>
